package com.chen.utils;

/**
 * @author chen
 * @version 1.0
 * @create_date 2025/8/20
 * 根据详细地址模拟获取经纬度信息工具类
 */
public class GeocodeUtils {
    public static Double getLatitude(String address) {
        StringBuilder sb = new StringBuilder(6);
        char[] chars = address.toCharArray();
        for (int i = 1; i < chars.length; i++) {
            if (i == 7) {
                break;
            }
            if (i == 2) {
                sb.append(".");
                continue;
            }
            sb.append(i);
        }
        return Double.valueOf(sb.toString());
    }

    public static Double getLongitude(String address) {
        StringBuilder sb = new StringBuilder(7);
        char[] chars = address.toCharArray();
        for (int i = 1; i < chars.length; i++) {
            if (i == 8) {
                break;
            }
            if (i == 2) {
                sb.append(".");
                continue;
            }
            sb.append(i);
        }
        return Double.valueOf(sb.toString());
    }
}
